package com.lancoo.ccas52.mapper;

import java.util.Collection;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lancoo.ccas52.entity.Major;
import com.lancoo.ccas52.entity.PlanTeaching;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lancoo.ccas52.config.MybatisRedisCache;
import com.lancoo.ccas52.entity.PlanTeachingCourseSegment;
import com.lancoo.ccas52.entity.Student;
import com.lancoo.ccas52.pojo.vo.TeachingClassCourseDto;
import com.lancoo.ccas52.pojo.vo.TeachingPlanDto;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 教务获取教学计划,相当于专业版本 Mapper 接口
 * </p>
 *
 * @author quin.song
 * @since 2022-12-30
 */
@CacheNamespace(implementation = MybatisRedisCache.class, eviction = MybatisRedisCache.class)
public interface PlanTeachingMapper extends BaseMapper<PlanTeaching> {

    int addBatch(@Param("planTeachingCollection") Collection<PlanTeaching> planTeachingCollection);


    /**
     * 获取教学任务相关数据
     *
     * @param taskId
     * @param collegeId 基础平台学院id
     * @param type      1:主修  2：辅修
     * @return
     */
    List<TeachingPlanDto> getTeachingPlanByCondition(@Param("taskId") Integer taskId, @Param("collegeId") String collegeId, @Param("type") Integer type, @Param("gradeId") String gradeId);

    /**
     * 获取没有选中该课程的教学计划
     *
     * @param taskId
     * @param flag
     * @param baseId
     * @return
     */
    List<TeachingPlanDto> getTeachingPlanNoCourse(@Param("taskId") Integer taskId, @Param("flag") Integer flag, @Param("baseId") String baseId, @Param("collegeId") String collegeId);

    /**
     * 获取教学计划详细信息
     *
     * @param teachPlanIds
     * @return
     */
    List<TeachingPlanDto> getTeachingPlanById(@Param("teachPlanIds") List<Long> teachPlanIds);

    /**
     * 根据教学计划id获取其课程、环节对应关系
     *
     * @param teachPlanIds
     * @return
     */
    List<PlanTeachingCourseSegment> getPlanTeachingCourseSegmentByTeachingPlanIds(@Param("taskId") Integer taskId, @Param("teachPlanIds") List<Long> teachPlanIds);


    /**
     * 根据课程id获取 含有该课程的教学计划
     *
     * @param courseId
     * @param studyNature
     * @return
     */
    List<PlanTeaching> getPlanTeachingByCourseId(@Param("courseId") Long courseId, @Param("studyNature") Integer studyNature, @Param("campusId") String campusId);

    /**
     * 根据环节id获取 含有该环节的教学计划
     * @param segmentId
     * @param studyNature
     * @param campusId
     * @return
     */
    List<PlanTeaching> getPlanTeachingBySegmentId(@Param("segmentId") Long segmentId, @Param("studyNature") Integer studyNature, @Param("campusId") String campusId);


    /**
     * 获取专业列表 通过教学计划表填充修读性质
     *
     * @param taskId
     * @param studyNature
     * @param collegeId
     * @param majorId
     * @param gradeId
     * @param keyWord
     * @return
     */
    Page<Major> getMajorJoinPlan(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("studyNature") Integer studyNature, @Param("collegeId") String collegeId,
                                 @Param("majorId") String majorId, @Param("gradeId") String gradeId, @Param("keyWord") String keyWord, @Param("state") Integer state);


    /**
     * 根据教学计划id列表获取学生
     *
     * @param taskId
     * @param baseTeachingPlanId
     * @return
     */
    List<Student> getStudentByPlanId(@Param("taskId") Integer taskId, @Param("baseTeachingPlanId") List<String> baseTeachingPlanId);

    /**
     * 根据教学计划 年级 专业 学院 获取课程
     * @param taskId
     * @param courseTypeId
     * @param courseNature
     * @param credit
     * @param keyWord
     * @param collegeId
     * @param majorId
     * @param gradeId
     * @return
     */
    List<TeachingClassCourseDto> getCourseByPlan(@Param("taskId") Integer taskId, @Param("courseTypeId") String courseTypeId,
                                                   @Param("courseNature") Integer courseNature, @Param("credit") Double credit, @Param("keyWord") String keyWord, @Param("collegeId") String collegeId, @Param("majorId") String majorId, @Param("gradeId") String gradeId);

    /**
     * 获取重修学生 课程
     * @param taskId
     * @param courseTypeId
     * @param courseNature
     * @param credit
     * @param keyWord
     * @param baseStudentId
     * @return
     */
    List<TeachingClassCourseDto> getCourseRetake(@Param("taskId") Integer taskId,@Param("schoolId") String schoolId,@Param("term") String term, @Param("courseTypeId") String courseTypeId,
                                                 @Param("courseNature") Integer courseNature, @Param("credit") Double credit, @Param("keyWord") String keyWord, @Param("baseStudentId") String baseStudentId,@Param("studyNature") Integer studyNature);
}
